package com.tcm.day03;

public class Code03_MyStack {

    public static class MyStack {
        Node head;
        int size;

        public MyStack() {
            head = null;
            size = 0;
        }

        public void push(int val) {
            Node node = new Node(val);
            if (head == null) {
                head = node;
            } else {
                node.next = head;
                head = node;
            }
            size++;
        }

        public int pop() {

            int ans = -1;
            if (head != null) {
                ans = head.val;
                head = head.next;
                size--;
            }
            return ans;
        }
    }

}
